<?php
include('config.php');


if(isset($_GET['email']) and isset($_GET['nombre']) and isset($_GET['voto'])){
$email = $_GET['email'];
$nombre = $_GET['nombre'];
$voto = $_GET['voto'];

$ipUsuario=getIP(); 

$insertEmail_sql = 'INSERT INTO liveconnectpolls (email,nombre,voto,ipAdress) VALUES("' . $email . '","'. $nombre .'","'.$voto .'",'. $ipUsuario . ')';
$insertEmail= mysql_query($insertEmail_sql) or die(mysql_error());
} else { 
echo 'Error! Please fill all fileds!';
}

function getIP() {  
    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {  
       $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];  
    }  
    elseif (isset($_SERVER['HTTP_VIA'])) {  
       $ip = $_SERVER['HTTP_VIA'];  
    }  
    elseif (isset($_SERVER['REMOTE_ADDR'])) {  
       $ip = $_SERVER['REMOTE_ADDR'];  
    }  
    else {  
       $ip = "unknown";  
    }  
    return "'$ip'";  
}  
?>